Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before you could only white-list certain attributes but not their values. I added the ability to specify values you want to white-list in the style attribute to filter out unwanted style values.
You can specify what styles you allow in the 'styles' array and what values you allow in certain style attributes through the 'cssValues' object, such as:
var sanitize = new Sanitize({
elements: ['a', 'br', 'li', 'ol', 'p', 'ul', 'span'],
attributes: {
a: ['data-id', 'href', 'target'],
span: ['class'],
'ALL': ['style']
},
protocols: {
a: { href: ['http', 'https', 'smartsheet'] }
},
styles: ["color", "background-color", "font-family", "font-size"],
cssValues: {
color: ["black", "red", "gray", "grey", "yellow", "white"],
backgroundColor: ["black", "red", "gray", "grey", "yellow", "white"],
fontFamily:["times new roman", "tahoma", "arial", "verdana"],
fontSize:["8pt", "9pt", "10pt", "12pt", "14pt", "16pt", "18pt", "20pt", "24pt", "28pt", "32pt", "36pt"]
}
});